/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DBFunction;

import org.json.JSONException;

import Constant.Constant;
import Json.LocationJson;
import Storage.Buddy;

public class fUpdateLocation {
	public static void process(String LocationJsonString) throws JSONException {
		Buddy buddy = LocationJson.process(LocationJsonString);
		String phone = buddy.getPhoneNumber();
		String lat = buddy.getLatitude();
		String log = buddy.getLongitude();
		String lastupdate = Constant.getDateTime();
		String sql = "UPDATE buddytracking.position set position.Latitude='"
				+ lat
				+ "',position.Longitude='"
				+ log
				+ "',position.LastUpdate='"
				+ lastupdate
				+ "' WHERE UserId = (select UserId from buddytracking.user where User.PhoneNumber='"
				+ phone + "')";
		DB.connectDB.Update(sql);
	}
}
